#include <iostream>
using namespace std;

int a[100005];
int sum[100005];
int main()
{
    int n,m,s=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s += a[i];
        sum[i] = s;
    }
    for(int z=1;z<=m;z++)
    {
        int i,j;
        cin>>i>>j;
        cout<<sum[j]-sum[i]+a[i]<<endl;
    }
    return 0;
}
